package org.fast.develop.logicflow.ws.task;

import org.fast.develop.logicflow.LogicFlowManagementConfiguration;
import org.fast.develop.logicflow.runtime.debug.ExecuteDebugConfig;
import org.fast.develop.logicflow.ws.message.StartMessage;

/**
 * @author czh
 * @version V1.0
 * @data Created on 2023-01-12 14:46
 */
public class LogicFlowDebugTask {


    private LogicFlowManagementConfiguration logicFlowManagementConfiguration;

    public LogicFlowDebugTask(LogicFlowManagementConfiguration logicFlowManagementConfiguration) {
        this.logicFlowManagementConfiguration = logicFlowManagementConfiguration;
    }

    public void run(String sessionId, StartMessage startMessage) {
        ExecuteDebugConfig debugConfig = ExecuteDebugConfig.OfDebug()
                .setStepOverFlag(false)
                .setSessionId(sessionId)
                .setType(startMessage.getType())
                .setDebugResourceIds(startMessage.getDebugResourceIds());
        logicFlowManagementConfiguration.getLogicFlowExecutorEnhance().execute(startMessage.getModelId(), startMessage.getVariables(), debugConfig);
    }
}
